package com.example.park2212.car

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.lib_base.mvvm.BaseActivity
import com.example.park2212.R
import com.example.park2212.adapter.CarAdapter
import com.example.park2212.databinding.ActivityCarBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch

@AndroidEntryPoint
@Route(path = "/app/car/CarActivity")
class CarActivity : BaseActivity<ActivityCarBinding,CarViewModel>() {
    lateinit var carAdapter: CarAdapter
    override fun initView() {
        carAdapter = CarAdapter()
        binding.rvCar.adapter = carAdapter
        binding.rvCar.layoutManager = LinearLayoutManager(this)
        viewModel.car(1)



    }

    override fun initData() {
        viewModel.carSuccess.observe(this){
            carAdapter.data.clear()
            carAdapter.data.add(it)
            carAdapter.notifyDataSetChanged()
        }
    }

}